// pages/invitation/invitation.js
import {
  request
} from '../../request/index.js'
Page({

  /**
   * 页面的初始数据
   */
  data: {
    codeUrl:'',
    show:false,
    user:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let user = typeof wx.getStorageSync('user')==='string'? JSON.parse(wx.getStorageSync('user')):wx.getStorageSync('user');
    this.setData({
      user
    });
    request({
      url:'QrCodeController/qrcode',
      method:'post',
      data:{
        user_id:this.data.user.user_id
      },
      responseType: 'arraybuffer',
    }).then(res=>{
      console.log(res);
      let url ='data:image/png;base64,'+wx.arrayBufferToBase64(res.data)
      this.setData({
        codeUrl:url,
        show:true
      })
    });
    
  },




})